package com.mnnu.controller;

import com.aliyuncs.exceptions.ClientException;
import com.mnnu.pojo.Result;
import com.mnnu.utils.AliOSSUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;

@RestController
@Slf4j
public class UploadController {

    @PostMapping("/upload")
    public Result upload(MultipartFile image) throws IOException, ClientException {
        log.info("上传文件");
        String url = AliOSSUtils.upload(image);
        return Result.success((Object) url);
    }
}
